package com.milling.common.utils.modbus;

import com.serotonin.modbus4j.exception.ModbusTransportException;

public interface ModbusTcpService {
    // 读取单个保持寄存器
    short readHoldingRegister(int slaveId, int registerAddress) throws ModbusTransportException;

    // 写入单个保持寄存器
    void writeHoldingRegister(int slaveId, int registerAddress, int value) throws ModbusTransportException;

    // 读取多个保持寄存器
    short[] readHoldingRegisters(int slaveId, int startOffset, int numberOfRegisters) throws ModbusTransportException;

    // 写入多个保持寄存器
    void writeHoldingRegisters(int slaveId, int startOffset, short[] values) throws ModbusTransportException;

    // 读取输入寄存器
    short[] readInputRegisters(int slaveId, int startOffset, int numberOfRegisters) throws ModbusTransportException;

    // 读取线圈状态
    boolean[] readCoils(int slaveId, int startOffset, int numberOfCoils) throws ModbusTransportException;

    // 写入单个线圈
    void writeCoil(int slaveId, int coilAddress, boolean value) throws ModbusTransportException;

    // 写入多个线圈
    void writeCoils(int slaveId, int startOffset, boolean[] values) throws ModbusTransportException;

    boolean[] readCoilsMitsubishi(int slaveId, int startAddress, int numberOfCoils) throws ModbusTransportException;

    String writeCoilMitsubishi(int slaveId, int coilAddress, boolean value) throws ModbusTransportException;

    String writeMultipleCoilsMitsubishi(int slaveId, int startAddress, boolean[] values) throws ModbusTransportException;

    Boolean readMXBit(int slaveId, int wordAddress, int bitPosition) throws ModbusTransportException;

    boolean writeMXBit(int slaveId, int mxWord, int mxBit, boolean value) throws ModbusTransportException;


}
